package com.bjsdzk.collector.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.stereotype.Component;

//@Component
public class ApplicationAllListener implements ApplicationListener<ApplicationEvent> {
    private Logger logger = LoggerFactory.getLogger(ApplicationAllListener.class);

    @Override
    public void onApplicationEvent(ApplicationEvent event) {

//        if (event instanceof ContextClosedEvent) {
//            logger.info(event.getClass().getSimpleName() + " 事件已发生！");
//        } else if (event instanceof ContextRefreshedEvent) {
//            logger.info(event.getClass().getSimpleName() + " 事件已发生！");
//        } else if (event instanceof ContextStartedEvent) {
//            logger.info(event.getClass().getSimpleName() + " 事件已发生！");
//        } else if (event instanceof ContextStoppedEvent) {
//            logger.info(event.getClass().getSimpleName() + " 事件已发生！");
//        } else {
//            logger.info("有其它事件发生:" + event.getClass().getName());
//        }
    }

}